//造retail数据
var List = [
    {
        id: '1000002',
        drugname: '头孢颗粒',
        drugunit: '药品规格',
        drugsinpr:'45',
        drugcount:1,
      }
]
import Mock from 'mockjs'

export default {
    getRetailData: () => {
        return {
            code: 200,
            msg: '请求成功',
            data: List
        }
    },
    delDrugData:drugcconfig=>{
        //根据id 删除一条数据
        console.log("drugcconfig",drugcconfig);
        // var id =JSON.parse(drugcconfig.body).id
        var {id} = JSON.parse(drugcconfig.body);
        var drugres = List.filter(drug=>drug.id != id)
        List = drugres
        return{
            code: 200,
            msg: '删除成功',
            data: null
        }
    },
    addlistData:config=>{
        const { id,drugname,drugunit,drugsinpr,drugcount } =JSON.parse(config.body)
        List.unshift({
            id:id,
            drugname:drugname,
            drugunit:drugunit,
            drugcount:drugcount,
            drugsinpr:drugsinpr,
        })
        return{
            code: 200,
            msg: '添加成功',
            data: null
        }
    }
    
}